package com.bestv.bsr.core.service.impl.zt.fallback;

import com.alibaba.csp.sentinel.slots.block.BlockException;
import com.bestv.bsr.core.service.impl.zt.dto.ZTResponseDto;
import com.bestv.remote.context.MethodContext;
import com.bestv.remote.context.ParamContext;
import com.bestv.remote.context.ServerContext;
import com.bestv.remote.interfaces.BlockHandler;
import com.bestv.remote.interfaces.FallbackHandler;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

/**
 * 中台服务 降级熔断处理
 *
 * @author taojiacheng
 */
@Service
@Slf4j
public class ZTFallbackHandler implements FallbackHandler<ZTResponseDto>, BlockHandler<ZTResponseDto> {

    @Override
    public ZTResponseDto handlerFallback(ServerContext serverContext, MethodContext methodContext, ParamContext paramContext, Throwable throwable) {
        log.info("bestv中台推荐接口请求<异常> 进入fallback 返回空对象");
        return new ZTResponseDto();
    }

    @Override
    public ZTResponseDto handlerBlock(ServerContext serverContext, MethodContext methodContext, ParamContext paramContext, BlockException blockException) {
        log.info("bestv中台推荐接口请求<已经熔断> 进入fallback 返回空对象");
        return new ZTResponseDto();
    }
}
